const int key = 3;
const int greenPin = 7;
const int redPin = 8;
const int bluedPin = 9;

void setup() {
    // put your setup code here, to run once:
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluedPin, OUTPUT);
}

void loop() {
    int key_status = digitalRead(key);
    int count = 0;
    if (key_status == 0)
    {
        count++;
    }
    
    if (count%3 == 0)
    {
      digitalWrite(redPin, HIGH); //点亮
      digitalWrite(greenPin, LOW); //点亮
      digitalWrite(bluedPin, LOW); //点亮
      delay(500); //延时500ms
      digitalWrite(redPin, LOW); //熄灭
      digitalWrite(greenPin, LOW); //熄灭
      digitalWrite(bluedPin, LOW); //熄灭
      delay(500); //延时500ms
    } 
    else if (count%3 == 1)
    {
      digitalWrite(redPin, LOW); //点亮
      digitalWrite(greenPin, HIGH); //点亮
      digitalWrite(bluedPin, LOW); //点亮
      delay(500); //延时500ms
      digitalWrite(redPin, LOW); //熄灭
      digitalWrite(greenPin, LOW); //熄灭
      digitalWrite(bluedPin, LOW); //熄灭
      delay(500); //延时500ms
    }
    else if (count%3 == 2)
    {
      digitalWrite(redPin, LOW); //点亮
      digitalWrite(greenPin, LOW); //点亮
      digitalWrite(bluedPin, HIGH); //点亮
      delay(500); //延时500ms
      digitalWrite(redPin, LOW); //熄灭
      digitalWrite(greenPin, LOW); //熄灭
      digitalWrite(bluedPin, LOW); //熄灭
      delay(500); //延时500ms
    }
}
